package com.listplayer;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class FileArrayAdapter extends ArrayAdapter<Option>{
	private Context c;
	private int id;
	private List<Option> items;
	
	public FileArrayAdapter(Context context, int textViewResourceId, List<Option> objects) {
		super(context, textViewResourceId, objects);
		c = context;
		id = textViewResourceId;
		items = objects;
	}
	
	@Override
	public Option getItem(int position) {
		return items.get(position);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if(v==null) {
			LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(id, null);
		}
		
		final Option o = items.get(position);
		if( o != null)
		{
			TextView t;
			t = (TextView)v.findViewById(R.id.TextView01);
			if (t != null )
				t.setText(o.getName());
			
			t = (TextView)v.findViewById(R.id.TextView02);
			if (t != null )
				t.setText(o.getData());
			
		}
		return v;
	}
	
	

}
